package com.molichuxing.gateway.api.services.impl;


import com.molichuxing.framework.dto.Paged;
import com.molichuxing.framework.exception.BizException;
import com.molichuxing.framework.result.ResponseCodeEnum;
import com.molichuxing.framework.result.ResponseResult;
import com.molichuxing.framework.utils.ObjectCastUtil;
import com.molichuxing.gateway.api.services.OrderApiService;
import com.molichuxing.gateway.bff.order.entity.request.create.PaymentOfflineCreateVo;
import com.molichuxing.gateway.bff.order.entity.request.modify.OrderDeliverySlipModifyVo;
import com.molichuxing.gateway.bff.order.entity.response.*;
import com.molichuxing.gateway.bff.order.services.*;
import com.molichuxing.gateway.utils.RequestAttrUtil;
import com.molichuxing.services.property.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * @Author: renzhengyu
 * @Description:
 * @Date: Created in 9:48 2019/9/10
 * @Modified By:
 **/
@Api(tags = "订单相关接口")
@RestController
@RequestMapping(value = "/order")
public class OrderApiServiceImpl extends RootApiService implements OrderApiService {
	private static final Logger logger = LoggerFactory.getLogger(OrderApiServiceImpl.class);

	@Resource
	private OrderBffService orderBffService;

	@Resource
	private OrderSubscribeBffService orderSubscribeBffService;

	@Resource
	private OrderExclusivelBffService orderExclusivelBffService;

	@Resource
	private OrderScheduleBffService orderScheduleBffService;

	@Resource
	private OrderDealerBffService orderDealerBffService;
	@Resource
	private OrderRenegeBffService orderRenegeBffService;


	@Override
	@ApiOperation(value = "获取经销商订单列表")
	@ApiImplicitParams({ @ApiImplicitParam(name = "orderType", value = "订单类型", required = false, dataType = "Integer"),
			@ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long"),
			@ApiImplicitParam(name = "dealerId", value = "经销商id", required = false, dataType = "Integer"),
			@ApiImplicitParam(name = "startTime", value = "开始时间", required = false, dataType = "String"),
			@ApiImplicitParam(name = "endTime", value = "结束时间", required = false, dataType = "String"),
			@ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, dataType = "Integer")

	})
	@GetMapping(value = "/dealer/purchase/list")
	public ResponseResult<Paged<OrderDealerVo>> orderDealerList(@RequestParam Map<String, Object> params,
			@RequestParam Integer pageNum, @RequestParam Integer pageSize) {

		ResponseResult<Paged<OrderDealerVo>> result = new ResponseResult<>();
		try {
			result.success(orderDealerBffService.orderDealerList(params, pageNum, pageSize));
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[orderDealerList]获取经销商订单列表异常", e);
			result.error("获取经销商订单列表异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "获取采购单信息详情 - 状态流转")
	@ApiImplicitParam(name = "orderCode", value = "订单号", required = true, dataType = "Long")
	@GetMapping(value = "/dealer/purchase/state/detail")
	public ResponseResult<OrderDealerStatusInfoVo> getDealerOrderFlow(@RequestParam Long orderCode) {
		ResponseResult<OrderDealerStatusInfoVo> result = new ResponseResult<>();
		try {
			result.success(orderDealerBffService.getDealerOrderFlow(orderCode));
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[getDealerOrderFlow]获取采购单信息详情 - 状态流转异常", e);
			result.error("获取采购单信息详情 - 状态流转异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "获取采购单信息详情 - 基础信息")
	@ApiImplicitParam(name = "orderCode", value = "订单号", required = true, dataType = "Long")
	@GetMapping(value = "/dealer/purchase/basics/detail")
	public ResponseResult<OrderDealerDetailBasicVo> orderDetailBasic(@RequestParam Long orderCode) {

		ResponseResult<OrderDealerDetailBasicVo> result = new ResponseResult<>();
		try {
			result.success(orderDealerBffService.orderDetailBasic(orderCode));
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[orderDetailBasic]获取采购单信息详情 - 基础信息异常", e);
			result.error("获取采购单信息详情 - 基础信息异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "获取采购单信息详情 - 采购车辆列表")
	@ApiImplicitParam(name = "orderCode", value = "订单号", required = true, dataType = "Long")
	@GetMapping(value = "/dealer/purchase/vehicle/detail")
	public ResponseResult<OrderDealerDetailVehicleVo> orderDetailVehicle(@RequestParam Long orderCode) {
		ResponseResult<OrderDealerDetailVehicleVo> result = new ResponseResult<>();
		try {
			result.success(orderDealerBffService.orderDetailVehicle(orderCode));
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[orderDetailVehicle]获取采购单信息详情 - 采购车辆列表异常", e);
			result.error("获取采购单信息详情 - 采购车辆列表异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "获取采购单信息详情 -获取还款信息列表")
	@ApiImplicitParam(name = "orderCode", value = "订单号", required = true, dataType = "Long")
	@GetMapping(value = "/dealer/purchase/repayment/detail")
	public ResponseResult<List<OrderDealerDetailScheduleVo>> orderSchedule(@RequestParam Long orderCode) {
		ResponseResult<List<OrderDealerDetailScheduleVo>> result = new ResponseResult<>();
		try {
			result.success(orderScheduleBffService.orderSchedule(orderCode));
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[orderSchedule]获取采购单信息详情 -获取还款信息列表异常", e);
			result.error("获取采购单信息详情 -获取还款信息列表异常");
		}
		return result;
	}



	@Override
	@ApiOperation(value = "获取发车收车列表")
	@ApiImplicitParams({ @ApiImplicitParam(name = "orderCode", value = "订单号", required = true, dataType = "Long"),
			@ApiImplicitParam(name = "carStatus", value = "车辆状态", required = true, dataType = "Integer") })
	@GetMapping(value = "/dealer/dispatcher/list")
	public ResponseResult<Paged<OrderDealerDetailStartVo>> orderDealerStartList(@RequestParam Long orderCode,
			@RequestParam Integer carStatus) {
		ResponseResult<Paged<OrderDealerDetailStartVo>> result = new ResponseResult<>();
		try {
			result.success(orderDealerBffService.orderDealerStartList(orderCode, carStatus));
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[orderDealerStartList]获取发车收车列表异常", e);
			result.error("获取发车收车列表异常");
		}
		return result;
	}


	@Override
	@ApiOperation(value = "车辆拒收")
	@ApiImplicitParams({ @ApiImplicitParam(name = "orderCode", value = "订单号", required = true, dataType = "Long"),
			@ApiImplicitParam(name = "carId", value = "车辆id", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "rejectReason", value = "拒收原因", required = true, dataType = "String") })
	@GetMapping(value = "/dealer/dispatcher/refused/modify")
	public ResponseResult<Boolean> orderDealerCarRefuse(@RequestParam Long orderCode, @RequestParam Integer carId,
			@RequestParam String rejectReason) {
		ResponseResult<Boolean> result = new ResponseResult<>();
		try {
			result.success(orderDealerBffService.orderDealerCarRefuse(orderCode, carId, rejectReason));
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[orderDealerCarRefuse]车辆拒收异常", e);
			result.error("车辆拒收异常");
		}
		return result;
	}



	@Override
	@ApiOperation(value = "保存交车单")
	@PostMapping(value = "/dealer/dispatcher/upload/modify")
	public ResponseResult<Boolean> modifyDeliverySlip(@RequestBody OrderDeliverySlipModifyVo orderDeliverySlipModifyVo) {
		ResponseResult<Boolean> result = new ResponseResult<>();
		try {
			result.success(orderDealerBffService.modifyDeliverySlip(orderDeliverySlipModifyVo));
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[modifyDeliverySlip]保存交车单异常", e);
			result.error("保存交车单异常");
		}
		return result;
	}



	@Override
	@ApiOperation(value = "获取经销商订单本期还款列表 - 还款计划")
	@ApiImplicitParams({ @ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long"),
			@ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, dataType = "Integer")

	})
	@GetMapping(value = "/repayment/current/list")
	public ResponseResult<Paged<OrderScheduleCurrentPeriodVo>> getOrderScheduleCurrentPeriodList(
			@RequestParam Map<String, Object> params,@RequestParam Integer pageNum,@RequestParam Integer pageSize) {
		ResponseResult<Paged<OrderScheduleCurrentPeriodVo>> result = new ResponseResult<>();
		try {
			result.success(orderScheduleBffService.getOrderScheduleCurrentPeriodList(params, pageNum, pageSize));
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[getOrderScheduleCurrentPeriodList]获取经销商订单本期还款列表 - 还款计划异常", e);
			result.error("获取经销商订单本期还款列表 - 还款计划异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "获取经销商订单逾期未还款列表 - 逾期未还款")
	@ApiImplicitParams({ @ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long"),
			@ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, dataType = "Integer")

	})
	@GetMapping(value = "/repayment/overdue/list")
	public ResponseResult<Paged<OrderScheduleOverdueVo>> getOrderScheduleOverdueList(@RequestParam Map<String, Object> params,
																					 @RequestParam Integer pageNum,@RequestParam Integer pageSize) {
		ResponseResult<Paged<OrderScheduleOverdueVo>> result = new ResponseResult<>();
		try {
			result.success(orderScheduleBffService.getOrderScheduleOverdueList(params, pageNum, pageSize));
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[getOrderScheduleOverdueList]获取经销商订单逾期未还款列表 - 逾期未还款异常", e);
			result.error("获取经销商订单逾期未还款列表 - 逾期未还款异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "获取还款信息详情 - 基础信息")
	@ApiImplicitParam(name = "orderCode", value = "订单号", required = true, dataType = "Long")
	@GetMapping(value = "/dealer/repayment/basics/detail")
	public ResponseResult<OrderDealerDetailBasicInfoVo> getDetailBasic(@RequestParam Long orderCode) {
		ResponseResult<OrderDealerDetailBasicInfoVo> result = new ResponseResult<>();
		try {
			result.success(orderScheduleBffService.getDetailBasic(orderCode));
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[getDetailBasic]获取还款信息详情 - 基础信息异常", e);
			result.error("获取还款信息详情 - 基础信息异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "获取还款计划详情-还款计划信息")
	@ApiImplicitParam(name = "orderCode", value = "订单号", required = true, dataType = "Long")
	@GetMapping(value = "/dealer/repayment/plan/detail")
	public ResponseResult<List<OrderDealerDetailScheduleVo>> orderSchedulePlan(@RequestParam Long orderCode) {
		ResponseResult<List<OrderDealerDetailScheduleVo>> result = new ResponseResult<>();
		try {
			result.success(orderScheduleBffService.orderSchedulePlan(orderCode));
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[orderSchedulePlan]获取还款计划详情-还款计划信息异常", e);
			result.error("获取还款计划详情-还款计划信息异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "获取还款信息详情 - 逾期信息")
	@ApiImplicitParam(name = "orderCode", value = "订单号", required = true, dataType = "Long")
	@GetMapping(value = "/dealer/repayment/expire/detail")
	public ResponseResult<List<OrderDealerDetailScheduleVo>> orderScheduleExpire(@RequestParam Long orderCode) {
		ResponseResult<List<OrderDealerDetailScheduleVo>> result = new ResponseResult<>();
		try {
			result.success(orderScheduleBffService.orderScheduleExpire(orderCode));
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[orderScheduleExpire]获取还款信息详情 - 逾期信息异常", e);
			result.error("获取还款信息详情 - 逾期信息异常");
		}
		return result;
	}


	@Override
	@ApiOperation(value = "订单线下支付列表")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "repayType", value = "还款类型(dealer:经销商, user:用户) ", required = true, dataType = "String"),
			@ApiImplicitParam(name = "serialNumber", value = "流水编号", required = false, dataType = "String"),
			@ApiImplicitParam(name = "auditStatus", value = "审核状态", required = false, dataType = "Integer"),
			@ApiImplicitParam(name = "dealerId", value = "经销商id", required = false, dataType = "Integer"),
			@ApiImplicitParam(name = "payName", value = "付款方姓名", required = false, dataType = "String"),
			@ApiImplicitParam(name = "startApplyTime", value = "开始时间", required = false, dataType = "String"),
			@ApiImplicitParam(name = "endApplyTime", value = "结束时间", required = false, dataType = "String"),
			@ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, dataType = "Integer") })
	@GetMapping(value = "/payment/offline/{repayType}/list")
	public ResponseResult<Paged<PaymentOfflineVo>> orderPaymentOfflineList(@PathVariable("repayType") String repayType,
																		   @RequestParam Map<String, Object> selectParams) {
		ResponseResult<Paged<PaymentOfflineVo>> result = new ResponseResult<>();
		try {
			if ("dealer".equals(repayType)) {
				// 经销商
				selectParams.put("repayType", OfflineRepayTypeEnum.DEALER);
			} else if ("user".equals(repayType)) {
				// 用户
				selectParams.put("repayType", OfflineRepayTypeEnum.USER);
			} else {
				return result.error("查询列表信息异常，不存在的还款类型");
			}

			result.success(orderScheduleBffService.getPaymentOfflinePage(selectParams,
					ObjectCastUtil.castInteger(selectParams.get("pageNum"), 1),
					ObjectCastUtil.castInteger(selectParams.get("pageSize"), 10)));
		} catch (BizException e) {
			logger.error("[orderPaymentOfflineList]查询订单线下支付列表异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[orderPaymentOfflineList]查询订单线下支付列表异常", e);
			result.error("查询列表信息异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "订单线下支付流水信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "offlineId", value = "线下支付id", required = true, dataType = "Integer") })
	@GetMapping(value = "/payment/offline/flow")
	public ResponseResult<PaymentOfflineVo> orderPaymentOfflineFlow(@RequestParam Integer offlineId) {
		ResponseResult<PaymentOfflineVo> result = new ResponseResult<>();
		try {
			result.success(orderScheduleBffService.getPaymentOfflineFlow(offlineId));
		} catch (IllegalArgumentException e) {
			logger.error("[orderPaymentOfflineFlow]根据线下支付id(" + offlineId + ")获取订单线下支付流水信息异常:", e);
			result.error(e.getMessage());
		} catch (BizException e) {
			logger.error("[orderPaymentOfflineFlow]根据线下支付id(" + offlineId + ")获取订单线下支付流水信息异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderPaymentOfflineFlow]根据线下支付id(" + offlineId + ")获取订单线下支付流水信息异常", e);
			result.error("查询订单线下支付流水信息异常:");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "订单线下支付排期信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "repayType", value = "还款类型(dealer:经销商, user:用户) ", required = true, dataType = "String"),
			@ApiImplicitParam(name = "offlineId", value = "线下支付id", required = true, dataType = "Integer") })
	@GetMapping(value = "/payment/offline/{repayType}/schedule/list")
	public ResponseResult<List<PaymentOfflineScheduleVo>> orderPaymentOfflineSchedule(
			@PathVariable("repayType") String repayType,@RequestParam  Integer offlineId) {
		ResponseResult<List<PaymentOfflineScheduleVo>> result = new ResponseResult<>();
		try {
			OfflineRepayTypeEnum repayTypeEnum = null;
			if ("dealer".equals(repayType)) {
				// 经销商
				repayTypeEnum = OfflineRepayTypeEnum.DEALER;
			} else if ("user".equals(repayType)) {
				// 用户
				repayTypeEnum = OfflineRepayTypeEnum.USER;
			} else {
				return result.error("查询订单线下支付排期信息异常，不存在的还款类型");
			}

			result.success(orderScheduleBffService.getPaymentOfflineSchedule(offlineId, repayTypeEnum));
		} catch (IllegalArgumentException e) {
			logger.error("[orderPaymentOfflineSchedule]根据线下支付id(" + offlineId + ")获取订单线下支付排期信息异常:", e);
			result.error(e.getMessage());
		} catch (BizException e) {
			logger.error("[orderPaymentOfflineSchedule]根据线下支付id(" + offlineId + ")获取订单线下支付排期信息异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderPaymentOfflineSchedule]根据线下支付id(" + offlineId + ")获取订单线下支付排期信息异常:", e);
			result.error("查询订单线下支付排期信息异常");
		}

		return result;
	}

	@Override
	@ApiOperation(value = "订单线下支付审核信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "offlineId", value = "线下支付id", required = true, dataType = "Integer") })
	@GetMapping(value = "/payment/offline/audit")
	public ResponseResult<PaymentOfflineAuditVo> orderPaymentOfflineAudit(@RequestParam Integer offlineId) {
		ResponseResult<PaymentOfflineAuditVo> result = new ResponseResult<>();
		try {
			result.success(orderScheduleBffService.getPaymentOfflineAudit(offlineId));
		} catch (IllegalArgumentException e) {
			logger.error("[orderPaymentOfflineAudit]根据线下支付id(" + offlineId + ")查询订单线下支付审核信息异常:", e);
			result.error(e.getMessage());
		} catch (BizException e) {
			logger.error("[orderPaymentOfflineAudit]根据线下支付id(" + offlineId + ")查询订单线下支付审核信息异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[orderPaymentOfflineAudit]根据线下支付id(" + offlineId + ")查询订单线下支付审核信息异常", e);
			result.error("查询订单线下支付审核信息异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "订单线下支付流水编号是否存在")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "serialNumber", value = "流水编号", required = true, dataType = "String") })
	@GetMapping(value = "/payment/offline/serialNumber/exists")
	public ResponseResult<Boolean> orderPaymentOfflineSerialNumberExists(@RequestParam String serialNumber) {
		ResponseResult<Boolean> result = new ResponseResult<>();
		try {
			result.success(orderScheduleBffService.getSerialNumberExists(serialNumber));
		} catch (IllegalArgumentException e) {
			result.error(ResponseCodeEnum.PARMS_ERROR.getCode(), e.getMessage());
		} catch (BizException e) {
			logger.error("[orderPaymentOfflineSerialNumberExists]查询订单线下支付流水编号(" + serialNumber + ")是否存在异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[orderPaymentOfflineSerialNumberExists]查询订单线下支付流水编号(" + serialNumber + ")是否存在异常", e);
			result.error("查询订单线下支付流水编号是否存在异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "经销商订单所有未还款订单")
	@GetMapping(value = "/dealer/wait/repay/list")
	public ResponseResult<List<OrderScheduleUnpaidVo>> getOrderScheduleUnpaid() {
		ResponseResult<List<OrderScheduleUnpaidVo>> result = new ResponseResult<>();
		try {
			result.success(orderScheduleBffService.getOrderScheduleUnpaid());
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[getOrderScheduleUnpaid]订单线下支付获取经销商下未所有还款订单异常", e);
			result.error("获取经销商下未所有还款订单异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "经销商订单支付未还款排期")
	@ApiImplicitParams({ @ApiImplicitParam(name = "orderCode", value = "订单号", required = true, dataType = "Long") })
	@GetMapping(value = "/dealer/wait/repay/schedule/list")
	public ResponseResult<List<OrderScheduleRelationVo>> orderDealerScheduleNoRepay(@RequestParam Long orderCode) {
		ResponseResult<List<OrderScheduleRelationVo>> result = new ResponseResult<>();
		try {
			result.success(orderScheduleBffService.getOrderScheduleRelationBizDto(orderCode));
		} catch (Exception e) {
			// 记录异常，返回异常信息
			logger.error("[getOrderScheduleRelationBizDto]订单线下经销商订单支付未还款排期异常", e);
			result.error("订单线下经销商订单支付未还款排期异常");
		}
		return result;
	}


	@Override
    @ApiOperation(value = "订单线下支付新增")
    @PostMapping(value = "/payment/offline/create")
    public ResponseResult<Boolean> createOrderPaymentOffline(@RequestBody @Valid PaymentOfflineCreateVo createVo,
                                                             BindingResult bindingResult) {
        ResponseResult<Boolean> result = new ResponseResult<>();
        try {
            result.success(orderScheduleBffService.createOrderPaymentOffline(createVo));
        } catch (IllegalArgumentException e) {
            logger.error("[createOrderPaymentOffline]订单线下支付新增异常:", e);
            result.error(e.getMessage());
        } catch (BizException e) {
            logger.error("[createOrderPaymentOffline]订单线下支付新增异常:", e);
            result.error(e.getExceptionCode(), e.getMessage());
        } catch (Exception e) {
            logger.error("[createOrderPaymentOffline]订单线下支付新增异常", e);
            result.error("新增订单线下支付失败");
        }
        return result;
	}

	@Override
	@ApiOperation(value = "订阅里程订单列表信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "listType", value = "列表类型(trade：交易列表，credit：征信审核，return：还车列表)", required = true, dataType = "String"),
			@ApiImplicitParam(name = "orderStatus", value = "订单状态", required = false, dataType = "Integer"),
			@ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long"),
			@ApiImplicitParam(name = "userName", value = "用户账号", required = false, dataType = "String"),
			@ApiImplicitParam(name = "userRealName", value = "用户姓名", required = false, dataType = "String"),
			@ApiImplicitParam(name = "userPhone", value = "用户手机号", required = false, dataType = "String"),
			@ApiImplicitParam(name = "storeId", value = "下单门店id", required = false, dataType = "Integer"),
			@ApiImplicitParam(name = "orderTimeStart", value = "下单开始时间", required = false, dataType = "String"),
			@ApiImplicitParam(name = "orderTimeEnd", value = "下单结束时间", required = false, dataType = "String"),
			@ApiImplicitParam(name = "isHaveSuborder", value = "有无续订(0：无，1：有)", required = false, dataType = "Integer"),
			@ApiImplicitParam(name = "refundStatus", value = "退款状态(15：待处理，16：退款中，17：已退款)", required = false, dataType = "Integer"),
			@ApiImplicitParam(name = "vin", value = "车架号", required = false, dataType = "String"),
			@ApiImplicitParam(name = "licencePlate", value = "车牌号", required = false, dataType = "String"),
			@ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, dataType = "Integer")})
	@GetMapping(value = "/subscribe/{listType}/list")
	public ResponseResult<Paged<OrderSubscribeVo>> orderSubscribeList(@PathVariable("listType") String listType,
			@RequestParam Map<String, Object> selectParams) {
		ResponseResult<Paged<OrderSubscribeVo>> result = new ResponseResult<>();
		try {
			// 转换参数
			if (listType.equals("trade")) {
				selectParams.put("listType", OrderListTypeEnum.TRADE_LIST);
			} else if (listType.equals("credit")) {
				// 征信审核
				selectParams.put("listType", OrderListTypeEnum.CREDIT_LIST);
				Integer refundStatus = ObjectCastUtil.castInteger(selectParams.get("refundStatus"));
				if (refundStatus != null) {
					selectParams.put("refundStatus", OrderSubscribeStatusEnum.getEnum(refundStatus));
				}
			}  else if (listType.equals("return")) {
				selectParams.put("listType", OrderListTypeEnum.RETURN_LIST);
			} else {
				return result.error(ResponseCodeEnum.PARMS_ERROR.getCode(), "列表类型错误");
			}
			Integer orderStatus = ObjectCastUtil.castInteger(selectParams.get("orderStatus"));
			if (orderStatus != null) {
				selectParams.put("orderStatus", OrderSubscribeStatusEnum.getEnum(orderStatus));
			}

			Paged<OrderSubscribeVo> data = orderSubscribeBffService.getOrderList(selectParams,
					RequestAttrUtil.getCurrentDealerId(),
					ObjectCastUtil.castInteger(selectParams.get("pageNum"), 1),
					ObjectCastUtil.castInteger(selectParams.get("pageSize"), 10));

			result.success(data);
		} catch (BizException e) {
			logger.error("[orderSubscribeList]查询订阅里程订单列表信息异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderSubscribeList]查询订阅里程订单列表信息异常:", e);
			result.error("查询订阅里程订单列表信息异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "订阅里程订单交易流程")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "listType", value = "列表类型(trade：交易列表，return：还车列表)", required = true, dataType = "String"),
			@ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long") })
	@GetMapping(value = "/subscribe/{listType}/flow")
	public ResponseResult<List<OrderTradeFlowVo>> orderSubscribeFlow(@PathVariable("listType") String listType,
			Long orderCode) {
		ResponseResult<List<OrderTradeFlowVo>> result = new ResponseResult<>();
		try {
			List<OrderTradeFlowVo> data = null;
			if (listType.equals("trade")) {
				data = orderSubscribeBffService.getOrderTradeFlow(orderCode, OrderListTypeEnum.TRADE_LIST);
			} else if (listType.equals("return")) {
				data = orderSubscribeBffService.getOrderTradeFlow(orderCode, OrderListTypeEnum.RETURN_LIST);
			} else {
				return result.error(ResponseCodeEnum.PARMS_ERROR.getCode(), "列表类型错误");
			}

			result.success(data);
		} catch (BizException e) {
			logger.error("[orderSubscribeFlow]查询订阅里程订单交易流程异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderSubscribeFlow]查询订阅里程订单交易流程异常:", e);
			result.error("查询订阅里程订单交易流程异常");
		}

		return result;
	}

	@Override
	@ApiOperation(value = "订阅里程订单基础信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "listType", value = "列表类型(trade：交易列表，return：还车列表)", required = true, dataType = "String"),
			@ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long") })
	@GetMapping(value = "/subscribe/{listType}/base")
	public ResponseResult<List<OrderSubscribeBaseVo>> orderSubscribeBase(@PathVariable("listType") String listType,
			Long orderCode) {
		ResponseResult<List<OrderSubscribeBaseVo>> result = new ResponseResult<>();
		try {
			List<OrderSubscribeBaseVo> data = orderSubscribeBffService.getOrderBaseList(orderCode, null);
			result.success(data);
		} catch (BizException e) {
			logger.error("[orderSubscribeDetails]查询订阅里程订单详情异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderSubscribeDetails]查询订阅里程订单详情异常:", e);
			result.error("查询订阅里程订单详情异常");
		}

		return result;
	}

	@Override
	@ApiOperation(value = "订阅里程订单用车实况")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "listType", value = "列表类型(trade：交易列表，return：还车列表)", required = true, dataType = "String"),
			@ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long") })
	@GetMapping(value = "/subscribe/{listType}/used/car")
	public ResponseResult<OrderUsedCarVo> orderSubscribeUsedCar(@PathVariable("listType") String listType,
			Long orderCode) {
		ResponseResult<OrderUsedCarVo> result = new ResponseResult<>();
		try {
			OrderUsedCarVo data = orderSubscribeBffService.getOrderUsedCar(orderCode);
			result.success(data);
		} catch (BizException e) {
			logger.error("[orderSubscribeUsedCar]查询订阅里程订单用车实况异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderSubscribeUsedCar]查询订阅里程订单用车实况异常:", e);
			result.error("查询订阅里程订单用车实况异常");
		}

		return result;
	}

	@Override
	@ApiOperation(value = "订阅里程订单费用交易明细")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "listType", value = "列表类型(trade：交易列表，return：还车列表)", required = true, dataType = "String"),
			@ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long") })
	@GetMapping(value = "/subscribe/{listType}/cost/detail")
	public ResponseResult<List<OrderCostDetailsVo>> orderSubscribeCostDetails(@PathVariable("listType") String listType,
			Long orderCode) {
		ResponseResult<List<OrderCostDetailsVo>> result = new ResponseResult<>();
		try {
			List<OrderCostDetailsVo> data = orderSubscribeBffService.getOrderCostDetails(orderCode);
			result.success(data);
		} catch (BizException e) {
			logger.error("[orderSubscribeCostDetails]查询订阅里程订单费用交易明细:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderSubscribeCostDetails]查询订阅里程订单费用交易明细:", e);
			result.error("查询订阅里程订单费用交易明细");
		}

		return result;
	}

	@Override
	@ApiOperation(value = "专属里程订单列表信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "listType", value = "列表类型(trade：交易列表，return：还车列表)", required = true, dataType = "String"),
			@ApiImplicitParam(name = "orderStatus", value = "订单状态", required = false, dataType = "Integer"),
			@ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long"),
			@ApiImplicitParam(name = "userName", value = "用户账号", required = false, dataType = "String"),
			@ApiImplicitParam(name = "userRealName", value = "用户姓名", required = false, dataType = "String"),
			@ApiImplicitParam(name = "userPhone", value = "用户手机号", required = false, dataType = "String"),
			@ApiImplicitParam(name = "storeId", value = "下单门店id", required = false, dataType = "Integer"),
			@ApiImplicitParam(name = "orderTimeStart", value = "下单开始时间", required = false, dataType = "String"),
			@ApiImplicitParam(name = "orderTimeEnd", value = "下单结束时间", required = false, dataType = "String"),
			@ApiImplicitParam(name = "renegeTimeStart", value = "退租开始时间", required = false, dataType = "String"),
			@ApiImplicitParam(name = "renegeTimeEnd", value = "退租结束时间", required = false, dataType = "String"),
			@ApiImplicitParam(name = "refundStatus", value = "退款状态(15：待处理，16：退款中，17：已退款)", required = false, dataType = "Integer"),
			@ApiImplicitParam(name = "vin", value = "车架号", required = false, dataType = "String"),
			@ApiImplicitParam(name = "licencePlate", value = "车牌号", required = false, dataType = "String"),
			@ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, dataType = "Integer")})
	@GetMapping(value = "/exclusivel/{listType}/list")
	public ResponseResult<Paged<OrderExclusivelVo>> orderExclusivelList(@PathVariable("listType") String listType,
			@RequestParam Map<String, Object> selectParams) {
		ResponseResult<Paged<OrderExclusivelVo>> result = new ResponseResult<>();
		try {
			// 转换参数
			if (listType.equals("trade")) {
				// 交易列表
				selectParams.put("listType", OrderListTypeEnum.TRADE_LIST);
			} else if (listType.equals("credit")) {
				// 征信审核
				selectParams.put("listType", OrderListTypeEnum.CREDIT_LIST);
				Integer refundStatus = ObjectCastUtil.castInteger(selectParams.get("refundStatus"));
				if (refundStatus != null) {
					selectParams.put("refundStatus", OrderSubscribeStatusEnum.getEnum(refundStatus));
				}
			} else if (listType.equals("renege")) {
				// 退租订单
				selectParams.put("listType", OrderListTypeEnum.RENEGE_LIST);
			} else {
				return result.error(ResponseCodeEnum.PARMS_ERROR.getCode(), "列表类型错误");
			}
			Integer orderStatus = ObjectCastUtil.castInteger(selectParams.get("orderStatus"));
			if (orderStatus != null) {
				selectParams.put("orderStatus", OrderExclusivelStatusEnum.getEnum(orderStatus));
			}

			Paged<OrderExclusivelVo> data = orderExclusivelBffService.getOrderList(selectParams,
					RequestAttrUtil.getCurrentDealerId(),
					ObjectCastUtil.castInteger(selectParams.get("pageNum"), 1),
					ObjectCastUtil.castInteger(selectParams.get("pageSize"), 10));

			result.success(data);
		} catch (BizException e) {
			logger.error("[orderExclusivelList]查询专属里程订单列表信息异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderExclusivelList]查询专属里程订单列表信息异常:", e);
			result.error("查询专属里程订单列表信息异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "专属里程订单交易流程")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "listType", value = "列表类型(trade：交易列表，return：还车列表)", required = true, dataType = "String"),
			@ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long") })
	@GetMapping(value = "/exclusivel/{listType}/flow")
	public ResponseResult<List<OrderTradeFlowVo>> orderExclusivelFlow(@PathVariable("listType") String listType,
			Long orderCode) {
		ResponseResult<List<OrderTradeFlowVo>> result = new ResponseResult<>();
		try {
			List<OrderTradeFlowVo> data = null;
			if (listType.equals("trade")) {
				data = orderExclusivelBffService.getOrderTradeFlow(orderCode, OrderListTypeEnum.TRADE_LIST);
			} else if (listType.equals("return")) {
				data = orderExclusivelBffService.getOrderTradeFlow(orderCode, OrderListTypeEnum.RETURN_LIST);
			} else {
				return result.error(ResponseCodeEnum.PARMS_ERROR.getCode(), "列表类型错误");
			}

			result.success(data);
		} catch (BizException e) {
			logger.error("[orderExclusivelFlow]查询专属里程订单交易流程异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderExclusivelFlow]查询专属里程订单交易流程异常:", e);
			result.error("查询专属里程订单交易流程异常");
		}

		return result;
	}

	@Override
	@ApiOperation(value = "专属里程订单基础信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "listType", value = "列表类型(trade：交易列表，return：还车列表)", required = true, dataType = "String"),
			@ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long") })
	@GetMapping(value = "/exclusivel/{listType}/base")
	public ResponseResult<OrderExclusivelBaseVo> orderExclusivelBase(@PathVariable("listType") String listType,
			Long orderCode) {
		ResponseResult<OrderExclusivelBaseVo> result = new ResponseResult<>();
		try {
			OrderExclusivelBaseVo data = orderExclusivelBffService.getOrderBase(orderCode);
			result.success(data);
		} catch (BizException e) {
			logger.error("[orderExclusivelBase]查询专属里程订单详情异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderExclusivelBase]查询专属里程订单详情异常:", e);
			result.error("查询专属里程订单详情异常");
		}

		return result;
	}

	@Override
	@ApiOperation(value = "专属里程订单费用交易明细")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "listType", value = "列表类型(trade：交易列表，return：还车列表)", required = true, dataType = "String"),
			@ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long") })
	@GetMapping(value = "/exclusivel/{listType}/cost/detail")
	public ResponseResult<List<OrderCostDetailsVo>> orderExclusivelCostDetails(
			@PathVariable("listType") String listType, Long orderCode) {
		ResponseResult<List<OrderCostDetailsVo>> result = new ResponseResult<>();
		try {
			List<OrderCostDetailsVo> data = orderExclusivelBffService.getOrderCostDetails(orderCode);
			result.success(data);
		} catch (BizException e) {
			logger.error("[orderExclusivelCostDetails]查询专属里程订单费用交易明细异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderExclusivelCostDetails]查询专属里程订单费用交易明细异常:", e);
			result.error("查询订阅里程订单费用交易明细异常");
		}

		return result;
	}

	@Override
	@ApiOperation(value = "专属里程订单还款明细")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "listType", value = "列表类型(trade：交易列表，return：还车列表)", required = true, dataType = "String"),
			@ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long") })
	@GetMapping(value = "/exclusivel/{listType}/repayment/detail")
	public ResponseResult<OrderExclusivelRepaymentDetailVo> orderExclusivelRepaymentDetail(
			@PathVariable("listType") String listType, Long orderCode) {
		ResponseResult<OrderExclusivelRepaymentDetailVo> result = new ResponseResult<>();
		try {
			OrderExclusivelRepaymentDetailVo data = orderExclusivelBffService
					.getOrderExclusivelRepaymentDetail(orderCode);
			result.success(data);
		} catch (BizException e) {
			logger.error("[orderExclusivelCostDetails]查询专属里程订单还款明细异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderExclusivelCostDetails]查询专属里程订单还款明细异常:", e);
			result.error("查询专属里程订单还款明细异常");
		}

		return result;
	}


	@Override
	@ApiOperation(value = "专属里程订单本期还款计划列表")
	@ApiImplicitParams({ @ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long"),
			@ApiImplicitParam(name = "userRealName", value = "用户姓名", required = false, dataType = "String"),
			@ApiImplicitParam(name = "userPhone", value = "用户手机号", required = false, dataType = "String"),
			@ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, dataType = "Integer") })
	@GetMapping(value = "/exclusivel/repayment/current/list")
	public ResponseResult<Paged<OrderRepaymentVo>> orderExclusivelCurrentPeriod(
			@RequestParam Map<String, Object> selectParams) {
		ResponseResult<Paged<OrderRepaymentVo>> result = new ResponseResult<>();
		try {
			Paged<OrderRepaymentVo> data = orderScheduleBffService.getExclusivelOrderCurrentPeriod(selectParams,
					RequestAttrUtil.getCurrentDealerId(),
					ObjectCastUtil.castInteger(selectParams.get("pageNum"), 1),
					ObjectCastUtil.castInteger(selectParams.get("pageSize"), 10));
			result.success(data);
		} catch (BizException e) {
			logger.error("[orderExclusivelCurrentPeriod]查询专属里程订单本期还款计划列表异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderExclusivelCurrentPeriod]查询专属里程订单本期还款计划列表异常:", e);
			result.error("查询专属里程订单本期还款计划列表异常");
		}

		return result;
	}

	@Override
	@ApiOperation(value = "专属里程订单逾期列表")
	@ApiImplicitParams({ @ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long"),
			@ApiImplicitParam(name = "userRealName", value = "用户姓名", required = false, dataType = "String"),
			@ApiImplicitParam(name = "userPhone", value = "用户手机号", required = false, dataType = "String"),
			@ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, dataType = "Integer") })
	@GetMapping(value = "/exclusivel/overdue/list")
	public ResponseResult<Paged<OrderOverdueVo>> orderExclusivelOverdue(
			@RequestParam Map<String, Object> selectParams) {
		ResponseResult<Paged<OrderOverdueVo>> result = new ResponseResult<>();
		try {
			Paged<OrderOverdueVo> data = orderScheduleBffService.getExclusivelOrderOverdue(selectParams,
					RequestAttrUtil.getCurrentDealerId(),
					ObjectCastUtil.castInteger(selectParams.get("pageNum"), 1),
					ObjectCastUtil.castInteger(selectParams.get("pageSize"), 10));
			result.success(data);
		} catch (BizException e) {
			logger.error("[orderExclusivelOverdue]查询专属里程订单逾期列表异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderExclusivelOverdue]查询专属里程订单逾期列表异常:", e);
			result.error("查询专属里程订单逾期列表异常");
		}

		return result;
	}

	@Override
	@ApiOperation(value = "专属里程订单还款排期列表")
	@ApiImplicitParams({@ApiImplicitParam(name = "orderCode", value = "订单号", required = false, dataType = "Long"),
			@ApiImplicitParam(name = "overdue", value = "是否只查询逾期", required = false, dataType = "Integer（0：否，1：是）")})
	@GetMapping(value = "/exclusivel/repayment/list")
	public ResponseResult<List<OrderRepaymentDetailVo>> orderRepaymentDetail(Long orderCode, Integer overdue) {
		ResponseResult<List<OrderRepaymentDetailVo>> result = new ResponseResult<>();
		try {
			List<OrderRepaymentDetailVo> data = orderScheduleBffService.getRepaymentDetail(orderCode,
					overdue == null ? false : overdue == 1 ? true : false);
			result.success(data);
		} catch (BizException e) {
			logger.error("[orderRepaymentDetail]查询专属里程订单还款排期列表异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderRepaymentDetail]查询专属里程订单还款排期列表异常:", e);
			result.error("查询专属里程订单还款排期列表异常");
		}

		return result;
	}

	@Override
	@ApiOperation(value = "根据用户id获取订单信息")
	@ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户id", required = true, dataType = "Integer") })
	@GetMapping(value = "/list/user")
	public ResponseResult<List<UserOrderVo>> orderByUser(Integer userId) {
		ResponseResult<List<UserOrderVo>> result = new ResponseResult<>();
		try {
			List<UserOrderVo> data = orderBffService.getOrderByUser(userId);
			result.success(data);
		} catch (BizException e) {
			logger.error("[orderByUser]根据用户id(" + userId + ")查询订单信息异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderByUser]根据用户id(" + userId + ")查询订单信息异常:", e);
			result.error("查询订单信息异常");
		}

		return result;
	}

	@Override
	@ApiOperation(value = "根据车辆id获取订单信息")
	@ApiImplicitParams({ @ApiImplicitParam(name = "carId", value = "车辆id", required = true, dataType = "Integer") })
	@GetMapping(value = "/list/car")
	public ResponseResult<List<CarOrderVo>> orderByCar(Integer carId) {
		ResponseResult<List<CarOrderVo>> result = new ResponseResult<>();
		try {
			List<CarOrderVo> data = orderBffService.getOrderByCar(carId, RequestAttrUtil.getCurrentDealerId());
			result.success(data);
		} catch (BizException e) {
			logger.error("[orderByCar]根据车辆id(" + carId + ")查询订单信息异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderByCar]根据车辆id(" + carId + ")查询订单信息异常:", e);
			result.error("查询订单信息异常");
		}

		return result;
	}

	@Override
	@ApiOperation(value = "合同/单据信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "documentType", value = "文件类型（contract：合同，sheet：取还单据）", required = true, dataType = "String"),
			@ApiImplicitParam(name = "orderCode", value = "订单号", required = true, dataType = "Long") })
	@GetMapping(value = "/document/{documentType}/list")
	public ResponseResult<List<OrderContractVo>> orderContract(@PathVariable("documentType") String documentType,
			Long orderCode) {
		ResponseResult<List<OrderContractVo>> result = new ResponseResult<>();
		DocumentTypeEnum documentTypeEnum = null;
		try {
			// 转换参数
			if ("contract".equals(documentType)) {
				documentTypeEnum = DocumentTypeEnum.CONTRACT;
			} else if ("sheet".equals(documentType)) {
				documentTypeEnum = DocumentTypeEnum.SHEET;
			} else {
				return result.error(ResponseCodeEnum.PARMS_ERROR.getCode(), "查询类型错误");
			}
			result.success(orderBffService.getOrderContract(orderCode, documentTypeEnum));
		} catch (IllegalArgumentException e) {
			logger.error("[orderContract]根据订单号(" + orderCode + ")查询" + documentTypeEnum.getName() + "信息异常:", e);
			result.error(e.getMessage());
		} catch (BizException e) {
			logger.error("[orderContract]根据订单号(" + orderCode + ")查询" + documentTypeEnum.getName() + "信息异常:", e);
			result.error(e.getExceptionCode(), e.getMessage());
		} catch (Exception e) {
			logger.error("[orderContract]根据订单号(" + orderCode + ")查询" + documentTypeEnum.getName() + "信息异常", e);
			result.error("查询" + documentTypeEnum.getName() + "信息异常");
		}
		return result;
	}

	@Override
	@ApiOperation(value = "查询订单审核信息")
	@ApiImplicitParams({ @ApiImplicitParam(name = "orderCode", value = "订单号", required = true, dataType = "Long") })
	@GetMapping(value = "/audit/info")
	public ResponseResult<OrderAuditVo> getOrderAudit(Long orderCode) {
		ResponseResult<OrderAuditVo> result = new ResponseResult<>();
		try {
			result.success(orderBffService.getOrderAudit(orderCode));
		} catch (BizException e) {
			logger.error("[getOrderAudit]查询订单审核信息失败:", e);
			result.error(e.getExceptionCode() == null ? ResponseCodeEnum.UNKNOWN_ERROR.getCode() : e.getExceptionCode(),
					e.getMessage());
		} catch (Exception e) {
			logger.error("[getOrderAudit]查询订单审核信息异常:", e);
			result.error("查询订单审核信息异常");
		}

		return result;
	}

	@Override
	@ApiOperation(value = "查询订单交易退款信息")
	@ApiImplicitParams({ @ApiImplicitParam(name = "orderCode", value = "订单号", required = true, dataType = "Long") })
	@GetMapping(value = "/trade/refund/info")
	public ResponseResult<OrderTradeRefundVo> getOrderTradeRefund(Long orderCode) {
		ResponseResult<OrderTradeRefundVo> result = new ResponseResult<>();
		try {
			result.success(orderBffService.getOrderTradeRefund(orderCode));
		} catch (BizException e) {
			logger.error("[getOrderTradeRefund]查询订单交易退款信息失败:", e);
			result.error(e.getExceptionCode() == null ? ResponseCodeEnum.UNKNOWN_ERROR.getCode() : e.getExceptionCode(),
					e.getMessage());
		} catch (Exception e) {
			logger.error("[getOrderTradeRefund]查询订单交易退款信息异常:", e);
			result.error("查询订单交易退款信息异常");
		}

		return result;
	}

	/**
	 * 查询订单退租信息
	 *
	 * @param orderCode
	 * @param userId
	 * @return
	 */
	@Override
	@ApiOperation(value = "查询订单退租信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "orderCode", value = "订单号", required = true, dataType = "Long"),
			@ApiImplicitParam(name = "userId", value = "用户id", required = true, dataType = "Integer")
	})
	@GetMapping(value = "/exclusivel/renege/info")
	public ResponseResult<OrderRenegeVo> getOrderRenege(Long orderCode, Integer userId) {
		ResponseResult<OrderRenegeVo> result = new ResponseResult<>();
		try {
			result.success(orderRenegeBffService.getOrderRenege(orderCode,userId));
		} catch (BizException e) {
			logger.error("[getOrderRenege]查询订单退租信息操作失败:", e);
			result.error(e.getExceptionCode() == null ? ResponseCodeEnum.UNKNOWN_ERROR.getCode() : e.getExceptionCode(),
					e.getMessage());
		} catch (Exception e) {
			logger.error("[getOrderRenege]查询订单退租信息操作异常:", e);
			result.error("查询订单退租信息操作异常");
		}

		return result;
	}
}
